import {
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  ManyToMany,
} from 'typeorm';
import { EntityModel } from '@midwayjs/orm';
import { SysRole } from './role';

@EntityModel('sys_user')
export class SysUser {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  userName: string;

  @Column()
  name: string;

  @Column()
  password: string;

  @Column()
  nickName: string;

  @Column()
  headImg: string;

  @Column()
  phone: string;

  @Column({ nullable: false })
  remark: string;

  @Column()
  status: number;

  @CreateDateColumn()
  createDate: Date;

  @UpdateDateColumn()
  updateDate: Date;
  @ManyToMany(() => SysRole, sysRole => sysRole.user, { cascade: true })
  role: SysRole[];
}
